<% content_for :page_head do %>
  <h1><%= link_to @issue.project.key, project_path(@issue.project) %><%="-Issue-" + @issue.issueid.to_s %></h1>
<% end %>

<% content_for :other_index do %>
  <span class="other_indexes">
    <%= link_to "编辑", edit_issue_url %>
  </span>
<% end %>

<div id="issue_info">
  <table style="text-align:left">
    <tbody>
      <tr><td width="20%" valign="top">优先级:</td><td width="80%" valign="top"><%= @issue.priority %></td></tr>
      <tr><td width="20%" valign="top">工程师:</td><td valign="top" id=<%= "b_" + @issue.id.to_s %> onclick="if($(this).firstChild.tagName != 'SELECT'){new Ajax.Updater('<%= "b_" + @issue.id.to_s %>', '<%= "/issues/" + @issue.id.to_s + "/change_developer" %>', {method: 'get'});}"><%= @issue.developer[0].name unless @issue.developer.empty? %><%= "无" if @issue.developer.empty? %></td></tr>
      <tr><td width="20%" valign="top">测试员:</td><td valign="top" ><%= @issue.reporter[0].name unless @issue.reporter.empty? %><%= "无" if @issue.reporter.empty? %></td></tr>
      <tr><td width="20%" valign="top">标题:</td><td valign="top"><%= @issue.title %></td></tr>
      <tr><td width="20%" valign="top">描述:</td><td valign="top"><%= @issue.description %></td></tr>
      <tr><td width="20%" valign="top">步骤:</td><td valign="top"><%= @issue.step %></td></tr>
      <tr><td width="20%" valign="top">比率:</td><td valign="top"><%= @issue.ratio %></td></tr>
      <tr><td width="20%" valign="top">手机卡类型:</td><td valign="top"><%= @issue.card_type %></td></tr>
      <tr><td width="20%" valign="top">测试样机:</td><td valign="top"><%= @issue.phoneid %></td></tr>
      <tr><td width="20%" valign="top">报告时间:</td><td valign="top"><%= @issue.created_at.to_date %></td></tr>
      <tr><td width="20%" valign="top">测试版本:</td><td valign="top"><%= @issue.tester_tags.collect {|t| t.name + " "} %></td></tr>
      <tr><td width="20%" valign="top">P1:</td><td valign="top"><%= @issue.P1 %></td></tr>
      <tr><td width="20%" valign="top">P2:</td><td valign="top"><%= @issue.P2 %></td></tr>
      <tr><td width="20%" valign="top">R:</td><td valign="top"><%= @issue.R %></td></tr>
      <tr><td width="20%" valign="top">S:</td><td valign="top"><%= @issue.S %></td></tr>
    </tbody>
  </table>
</div>
<h2>该问题的回复及记录</h2>

<% for log in @issue.logs %>
<div id ="comments_and_logs">
  <% if log.log_type == "system" %>
    <div id="comments_and_logs_title">
      <span class="create_time"><%= log.created_at.to_s %></span>
      <%= "用户 " + log.user.name + " 改变了状态 " %>
    </div>
    <div id="comments_and_logs_content">
    <% if log.ex_issue_user_id == 0 %>
    <%= "旧值: " + "无 ----> 新值: " + User.find(log.current_issue_user_id).name%>
    <% else %>
      <%= "旧值: " + User.find(log.ex_issue_user_id).name + " ----> 新值: " + User.find(log.current_issue_user_id).name%>
    <% end %>
    </div>
  <% elsif log.log_type == "user" %>
    <div id="comments_and_logs_title">
      <span class="create_time"><%= log.created_at.to_s %></span>
      <%= "用户 " + log.user.name %>
    </div>
    <div id="comments_and_logs_content">
      <%= "内容: " + log.content %>
    </div>
  <% end %>
</div>
<% end %>

<% form_for :comment, @comment, :url => issue_comments_path(@issue) do |f| %>
  <%= f.error_messages %>
<p>
  <%= f.label :content, "提交新回复" %>
</p>
<p>
  <%= f.text_area :content %>
</p>

<p><%= f.submit "提交" %></p>
<% end %>

<% content_for :right_side do %>
  <p style="color:#999999;">目前该项目的状态为： <%= trans_current_state_to_chs @issue.project.state %></p>
  <p style="color:#999999;">目前该Issue的状态为： <%= trans_issue_state_to_chs @issue.state %></p>
  <h2>对该Issue的状态进行变更</h2>
  <% if @issue.state == "assigned" || @issue.state == "reopen" %>
    <div id="the_other_control">
      <%= link_to image_tag("add_icon.gif"), {:controller => "issues", :action => "change_state", :id => @issue, :op_code => "working"}, :confirm => '该Issue的状态将转变成待测试，并将加入最新的版本标签中，确定吗？',:class=>"image"%>
      <%= link_to "解决问题", {:controller => "issues", :action => "change_state", :id => @issue, :tag_id => :tag,:op_code => "working"}, :confirm => '该Issue的状态将转变成待测试，并将加入最新的版本标签中，确定吗？', :class=>"grey" %>
    </div>
  <% end %>
  <% if @issue.state == "resolved" || @issue.state == "finished" || @issue.state == "suspend" %>
    <div id="the_other_control">
      <%= link_to image_tag("add_icon.gif"), {:controller => "issues", :action => "change_state", :id => @issue, :op_code => "rework"}, :confirm => '该Issue的状态将转变成重新开启，确定吗？', :class=>"image"%>
      <%= link_to "重新开启", {:controller => "issues", :action => "change_state", :id => @issue, :op_code => "rework"}, :confirm => '该Issue的状态将转变成重新开启，确定吗？', :class=>"grey" %>
    </div>
  <% end %>
  <% if @issue.state == "reopen" || @issue.state == "assigned" || @issue.state == "submitted" %>
    <div id="the_other_control">
      <%= link_to image_tag("download.gif"), {:controller => "issues", :action => "change_state", :id => @issue, :op_code => "hang_up"},:confirm => '该Issue的状态将转变成挂起，确定吗？', :class=>"image"%>
      <%= link_to "挂起", {:controller => "issues", :action => "change_state", :id => @issue, :op_code => "hang_up"}, :confirm => '该Issue的状态将转变成挂起，确定吗？', :class=>"grey" %>
    </div>
  <% end %>
  <% if @issue.state == "resolved" %>
    <div id="the_other_control">
      <%= link_to image_tag("add_icon.gif"), {:controller => "issues", :action => "change_state", :id => @issue, :op_code => "working"}, :confirm => '该Issue的状态将转变成关闭，确定吗？',:class=>"image"%>
      <%= link_to "关闭问题", {:controller => "issues", :action => "change_state", :id => @issue, :op_code => "working"}, :confirm => '该Issue的状态将转变成关闭，确定吗？', :class=>"grey" %>
    </div>
  <% end %>
<% end %>